package api

import (
	"github.com/gin-gonic/gin"
	"go-malphite/app/common/resp"
	"go-malphite/app/model"
	"go-malphite/app/service"
)

// GetCaptchaByLogin
// @Summary 获取验证码
// @Tags 验证码模块
// @Success 200 {object} resp.Response{data=model.CaptchaRes}
// @Router /api/v1/captcha/login [get]
func GetCaptchaByLogin(c *gin.Context) {
	id, b64, err := service.CreateCaptchaByString()
	if err != nil {
		resp.FailWithMsg(c, "获取验证码失败！")
		return
	}
	data := model.CaptchaRes{
		Key:   id,
		Value: b64,
	}
	resp.OkWithData(c, data, "获取验证码成功！")
}
